package org.hz.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Scanner;

public class AccssSocket1 {
	public static void main(String[] args) throws IOException {
		InetAddress addr = InetAddress.getByName("localhost");
		while(true){
			Socket socket = new Socket(addr,8080);
			PrintWriter pw = new PrintWriter(socket.getOutputStream());
			Scanner sc = new Scanner(System.in);
			pw.println(sc.nextInt());
			pw.println();
			pw.flush();
			
			BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream(),"UTF-8"));
			String s1 = rd.readLine();
			System.out.println(s1);
		}
	}
	
}
